package com.woniu.micropropertyserver.mapper;


import com.sun.org.apache.bcel.internal.generic.NEW;
import com.woniu.microcommonsserver.entity.DeployTenement;
import com.woniu.microcommonsserver.entity.TenementFaceCheck;
import com.woniu.micropropertyserver.util.PageRest;
import org.apache.ibatis.annotations.*;

import javax.tools.JavaCompiler;
import java.util.Date;
import java.util.HashMap;
import java.util.List;

/**
 * @author ：zhengbin
 * @date ：Created in 2021/1/25 0025
 * @description：
 * @modified By：
 * @version: $
 */
@Mapper
public interface TenementFaceMapper {

    @ResultType(DeployTenement.class)
    @Select("select id,t.passer_id passerId,t.passer_type passerType,t.authorize_status authorizeStatus,t.authorize_start_date authorizeStartDate,t.authorize_end_date  authorizeEndDate ,o.name name,o.phone phone,o.card_type cardType,o.card_id  cardId,o.house_num houseNum,from Tenement_face_check t, owner_info o where t.passer_type=0 and t.passer_id=o.id " +
            "union all select id,t.passer_id passerId,t.passer_type passerType,t.authorize_status authorizeStatus,t.authorize_start_date authorizeStartDate,t.authorize_end_date  authorizeEndDate ,r.name name,r.phone phone,r.card_type cardType,r.card_id  cardId,r.house_num houseNum,from Tenement_face_check t, relatives_info r where t.passer_type=1 and t.passer_id=r.id" +
            "union all select id,t.passer_id passerId,t.passer_type passerType,t.authorize_status authorizeStatus,t.authorize_start_date authorizeStartDate,t.authorize_end_date  authorizeEndDate ,r.name name,r.phone phone,r.card_type cardType,r.card_id  cardId,r.house_num houseNum,from Tenement_face_check t, renter_info r where t.passer_type=2 and t.passer_id=r.id")
    List<DeployTenement> findAll();



 /*   @Select("select id,t.passer_id passerId,t.passer_type passerType,t.authorize_status authorizeStatus,t.authorize_start_date authorizeStartDate,t.authorize_end_date  authorizeEndDate ,r.name name,r.telephone telephone,r.card_type cardType,r.card_num  cardNum,r.house_num houseNum,from Tenement_face_check t, relatives_info r where t.passer_type=1 and t.passer_id=r.id")
    List<HashMap> findAllRelatives();

    @Select("select id,t.passer_id passerId,t.passer_type passerType,t.authorize_status authorizeStatus,t.authorize_start_date authorizeStartDate,t.authorize_end_date  authorizeEndDate ,r.name name,r.telephone telephone,r.card_type cardType,r.card_num  cardNum,r.house_num houseNum,from Tenement_face_check t, renter_info r where t.passer_type=2 and t.passer_id=r.id")
    List<HashMap> findAllRenter();
*/

    List<DeployTenement> findByParams(PageRest pageRest, @Param("d") DeployTenement deployTenement);

    int delInfo( Long[] ids);

    int updateAuth(@Param("ids") Long[] ids, @Param("t") TenementFaceCheck tenementFaceCheck, @Param("now")Date now);
    @Options(
            useGeneratedKeys = true,
            keyProperty = "t.id"
    )
    @Insert("insert into Tenement_face_check (id,passer_id,passer_type ,authorize_status ,authorize_start_date ,authorize_end_date) values(null,#{t.passerId},#{t.passerType},#{t.authorizeStatus},#{t.authorizeStartDate},#{t.authorizeEndDate})")
    int saveInfo(@Param("t") TenementFaceCheck tenementFaceCheck);
}
